package com.example.tuter.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.tuter.R;
import com.example.tuter.util.Constant;
import com.example.tuter.util.SPUtils;
import com.example.tuter.util.httpUtil.RetrofitFactory;

public class SettingsActivity extends BaseActivity {

    private static final String TAG=SettingsActivity.class.getSimpleName();

    private Button button_logout;
    private ImageView imageView_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void bindEvent() {
        imageView_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });


        button_logout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //刷新当前用户内容，清除缓存。
                SPUtils.clear(SettingsActivity.this);
                RetrofitFactory.reset();
                Constant.r = RetrofitFactory.getBaseInstance();
                Toast.makeText(SettingsActivity.this,"已退出登录",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(SettingsActivity.this,WelcomingActivity.class));
                finish();
            }
        });
    }

    @Override
    protected void initView() {
        setContentView(R.layout.activity_settings);

        button_logout = (Button)findViewById(R.id.button_login_out);
        imageView_back = (ImageView)findViewById(R.id.activity_mine_shezhi_imageView);
    }

    @Override
    protected int getLayoutID() {
        return R.layout.activity_settings;
    }
}
